//
//  moodHeaderView.m
//  NewMusic
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "moodHeaderView.h"

@interface moodHeaderView ()
@property (nonatomic, retain) UIImageView *weatherIamgeView;
@property (nonatomic, retain) UILabel *titleLabel;
@end

@implementation moodHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}
- (void)createSubView {
    self.weatherIamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 20)];
    self.weatherIamgeView.image = [UIImage imageNamed:@"qing"];
    [self addSubview:_weatherIamgeView];
    [_weatherIamgeView release];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.frame.size.width - 100, self.weatherIamgeView.frame.size.height - 30, 100, 30)];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.text = @"晴";
    [self.weatherIamgeView addSubview:self.titleLabel];
    [self.titleLabel release];
}
- (void)setWeatherString:(NSString *)weatherString {
    if (_weatherString != weatherString) {
        [_weatherString release];
        _weatherString = [weatherString copy];
    }
    self.titleLabel.text = weatherString;
    if ([weatherString containsString:@"阴"]) {
        self.weatherIamgeView.image = [UIImage imageNamed:@"duoyun"];
    }else
        if ([weatherString containsString:@"雨"]) {
        self.weatherIamgeView.image = [UIImage imageNamed:@"xiayu"];
    }else if ([weatherString containsString:@"雪"]) {
        self.weatherIamgeView.image = [UIImage imageNamed:@"xiaxue"];
    }else {
        self.weatherIamgeView.image = [UIImage imageNamed:@"qing"];
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
